<template>
  <view class="ly-modal" v-if="show">
    <view class="ly-mask" @tap.stop="$emit('update:show', false)"></view>
    <view class="ly-modal-container" :style="{ width }">
      <view class="ly-modal-hd" :class="hdClasses">
        <view class="ly-modal-title" v-text="title"></view>
        <view class="cuIcon-close" @tap="$emit('update:show', false)"></view>
      </view>
      <view class="ly-modal-bd"><slot></slot></view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },
    title: String,
    hdClasses: {
      type: [String, Array, Object],
      default: ""
    },
    width: {
      type: String,
      default: "70%"
    },
    mask: {
      type: Boolean,
      default: true
    }
  }
};
</script>

<style lang="scss" scoped>
.ly-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 999;
  display: block;
  box-sizing: border-box;
  .ly-mask {
    position: fixed;
    z-index: 999;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
  }
  .ly-modal-container {
    position: fixed;
    z-index: 999;
    max-width: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    border-radius: 3px;
    overflow: hidden;
    .ly-modal-hd {
      font-size: 30upx;
      height: 70upx;
      line-height: 70upx;
      text-align: center;
      .cuIcon-close {
        position: absolute;
        width: 60upx;
        right: 0;
        top: 0;
        height: 70upx;
        color: #9aa2af;
      }
    }
    .ly-modal-bd {
      padding: 10upx 20upx;
    }
  }
}
</style>
